<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>兑奖点日结报表</title>
<script type="text/javascript" src="../script/common.js"></script>
<script type="text/javascript" language="javascript" src="../script/common_stat.js"></script>

<style>
</style>

<script type="text/javascript">
	var crosstab = new Crosstab();
	
	var dimensions = {"province":"城市","org":{name:"所属机构",option:{"p700":"兑奖点"}},"name":"礼品名称","catname":"类别"}
	var measures = {"count":"数量"}
	var defaultHorizon = {"province":true,"org":{"p700":true},"name":true}
	var defaultVertical = {}
	var defaultMeasure = {"sum":true}
	var crossconf = {
		dimensions : dimensions,
		measures : measures,
		defaultMeasure : defaultMeasure,
		defaultVertical : defaultVertical,
		defaultHorizon : defaultHorizon
	}
	var pivot;
    var pivot1;
    var pivot2;
    var pivot3;
	function load(){
		Eui.showNavigation();
		setPages(["queryView","crosstabview","crosstabview1","crosstabview2","crosstabview3"]);
		Eui.initDateInput("confirmDateId","业务日期","searchForm","confirmDate","_pastDate",true);
		searchForm.confirmDate.value = TX.Misc.getDateBefore(1);//默认日期,昨天
		pivot = new Pivot("crosstabview","gift_info_stat");		
		pivot.initConf(crossconf);
		pivot.setPivotHead('pivotTitle','兑奖点日结报表-礼品验证入库报表');
		pivot1 = new Pivot("crosstabview1","gift_info_stat");		
		pivot1.initConf(crossconf);
		pivot1.setPivotHead('pivotTitle','兑奖点日结报表-领奖出库报表');
		pivot2 = new Pivot("crosstabview2","gift_info_stat");		
		pivot2.initConf(crossconf);
		pivot2.setPivotHead('pivotTitle','兑奖点日结报表-礼品退货出库报表');
		pivot3 = new Pivot("crosstabview3","gift_info_stat");		
		pivot3.initConf(crossconf);
		pivot3.setPivotHead('pivotTitle','兑奖点日结报表-礼品报废报表');
	}
	
	function doQuery(){
		if(!checkForm("searchForm"))
				return;	
		var flag=$("searchForm").status.value;

		switch(flag){
		case "1":
		pivot.setPivotHead('statTime',Format.today(true));
		pivot.setPivotHead('statClass',"无");
		pivot.setPivotHead('beginTime','');
		pivot.setPivotHead('endTime','');
		pivot.param = paramFunc();
		pivot.refresh();
		switchPage("crosstabview");
		break;
		case "2":
		pivot1.setPivotHead('statTime',Format.today(true));
		pivot1.setPivotHead('statClass',"无");
		pivot1.setPivotHead('beginTime','');
		pivot1.setPivotHead('endTime','');
		pivot1.param = paramFunc();
		pivot1.refresh();		
		switchPage("crosstabview1");
		break;
		case "3":
		pivot2.setPivotHead('statTime',Format.today(true));
		pivot2.setPivotHead('statClass',"无");
		pivot2.setPivotHead('beginTime','');
		pivot2.setPivotHead('endTime','');
		pivot2.param = paramFunc();
		pivot2.refresh();		
		switchPage("crosstabview2");
		break;
		case "4": 
		pivot3.setPivotHead('statTime',Format.today(true));
		pivot3.setPivotHead('statClass',"无");
		pivot3.setPivotHead('beginTime','');
		pivot3.setPivotHead('endTime','');
		pivot3.param = paramFunc();
		pivot3.refresh();		
		switchPage("crosstabview3");
		break;
		}
		}
		function paramFunc(){
		var cOrg = Common.cOrg();
		var tDate=searchForm.confirmDate.value;
		tDate=tDate.replace("-","/");
		var vDate=new Date(tDate);
		vDate.setDate(vDate.getDate()+1);
		searchForm.endDate.value= vDate.getFullYear() + "-" +(vDate.getMonth() + 1) + "-" + vDate.getDate(); 
		searchForm.currentOrg.value = cOrg.id;
		searchForm.currentOrgLevel.value = cOrg.orgLevel;
		return Common.getValues(searchForm);
	}
	//选择单位控件
	function setOrg(sorg) {
		searchForm.orgLevel.value = sorg.orgLevel;
		searchForm.orgId.value = sorg.id;
		searchForm.orgName.value = sorg.name;
	}
		
</script>
</head>
	
	<body onload="load()">
		<div class="nav"><div id="nav">&nbsp;</div></div>
		<div id="getHtmlPrintdiv" style="display:none;"></div>
		<div id="queryView" class="searchForm">
		<div class="formTitle">日结统计：查询条件</div>
			<form id="searchForm" name="searchForm">
			<input type="hidden" name="orgId"/>
			<input type="hidden" name="orgLevel"/>
			<input type="hidden" name="currentOrg"/>
			<input type="hidden" name="currentOrgLevel"/>	
				<table cellSpacing="0" cellPadding="4" width="100%" border="0">
					<tr>	
						<td id="confirmDateId"></td>
					
						<td><label>报表类型</label> <select name="status">
						     <option>请选择</option>						       
						     <option value=1>礼品验证入库报表</option>
						     <option value=2>领奖出库报表</option>
						     <option value=3>礼品退货出库报表</option>
						     <option value=4>礼品报废报表</option>
						     </select>
						</td>
						<td><button onclick="doQuery()">查询报表</button>
						</td>
					</tr>
				</table>
				<input type="hidden" name="endDate"/>
			</form>
		</div>
		<div id="crosstabview" style="display:none;"></div>
		<div id="crosstabview1" style="display:none;"></div>
		<div id="crosstabview2" style="display:none;"></div>
		<div id="crosstabview3" style="display:none;"></div>
		<div id="pirotView" style="display:none"></div>
	</body>
</html>
